home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / TECHFUN.ZIP / TECHFUN.CPP < prev    next >
C/C++ Source or Header  |  1995-05-23  |  2KB  |  98 lines

  1. // Black Magic TechnoFun effect by Kaos (a.k.a. Bruno Carlos)
  2.  
  3. // If you use this code in any of your
  4. // productions give us the proper credits...
  5.  
  6. #include <dos.h>
  7. #include <math.h>
  8. #include <stdio.h>
  9. #include <process.h>
  10. #include <alloc.h>
  11. #include <mem.h>
  12. #include "xmode.h"
  13.  
  14. char *Ptr(char far *ptr, unsigned int l)
  15. {
  16.  unsigned int seg, off;
  17.  
  18.  seg=FP_SEG(ptr);
  19.  off=FP_OFF(ptr);
  20.  
  21.  seg+=(off/16);
  22.  off&=0x000f;
  23.  off+=(unsigned int)(l & 0x000fL);
  24.  seg+=(l/16L);
  25.  ptr=(char *)MK_FP(seg, off);
  26.  
  27.  return(ptr);
  28. }
  29.  
  30. void technofun(void)
  31. {
  32.  FILE *temp;
  33.  unsigned char *buffer1;
  34.  int i,a,b;
  35.  unsigned Locs1[500];
  36.  unsigned Locs2[300];
  37.  unsigned char pal[768];
  38.  
  39.  #define Pi 3.1415927
  40.  
  41.  for (i=0; i<500; i+=2)
  42.      {
  43.       Locs1[i]=(int)(40*sin((2*Pi/250)*i))+40;
  44.       Locs1[i+1]=(int)(10*sin((2*Pi/500)*i))+10;
  45.      }
  46.  
  47.  for (i=0; i<300; i+=2)
  48.      {
  49.       Locs2[i]=(int)(40*sin((2*Pi/300)*i))+40;
  50.       Locs2[i+1]=(int)(10*sin((2*Pi/150)*i))+10;
  51.      }
  52.  
  53.  if ((temp=fopen("circles.xcr","rb"))==NULL) exit(101);
  54.  if ((buffer1=(unsigned char *)farmalloc(89920))==NULL) exit(101);
  55.  fread(buffer1,64000,1,temp);
  56.  fread((unsigned char *)MK_FP(FP_SEG(buffer1)+4000,4),1,25920,temp);
  57.  fclose(temp);
  58.  
  59.  xinitvideo(0);
  60.  xclrvram();
  61.  
  62.  pal[0]=0;
  63.  pal[1]=0;
  64.  pal[2]=0;
  65.  pal[3]=0x20;
  66.  pal[4]=0x20;
  67.  pal[5]=0x20;
  68.  pal[6]=0x30;
  69.  pal[7]=0x30;
  70.  pal[8]=0x30;
  71.  
  72.  xsetpalette(pal);
  73.  
  74.  for (i=0,a=0,b=0; i<800; i+=1,a+=4,b+=4)
  75.      {
  76.       if (a==500) a=0;
  77.       if (b==300) b=0;
  78.       xsetvpage(1);
  79.       xvwait();
  80. //      xsetborder(1);
  81.       movewin(Ptr(buffer1+Locs1[a]*320/4+Locs1[a+1],0),Ptr(buffer1+Locs2[b]*320/4+Locs2[b+1],0),0);
  82. //      xsetborder(0);
  83.       xsetvpage(0);
  84.       xvwait();
  85. //      xsetborder(1);
  86.       movewin(Ptr(buffer1+Locs1[a+2]*320/4+Locs1[a+3],0),Ptr(buffer1+Locs2[b+2]*320/4+Locs2[b+3],0),1);
  87. //      xsetborder(0);
  88.      }
  89.  
  90.  farfree(buffer1);
  91. }
  92.  
  93. void main()
  94. {
  95.  technofun();
  96.  xtextmode(25);
  97. }
  98.